Learn Angular: 4 Angular Projects by Manjunath M & Jeremy Wilken & Simon Holmes & Ilya Bodrov-Krukowski

Learn Angular: 4 Angular Projects by Manjunath M & Jeremy Wilken & Simon Holmes & Ilya Bodrov-Krukowski

Author:Manjunath M & Jeremy Wilken & Simon Holmes & Ilya Bodrov-Krukowski [M, Manjunath]
Language: eng
Format: epub
Publisher: SitePoint
Published: 2018-06-14T23:00:00+00:00


Getting Data from a JWT

When we set the data for the JWT (in the generateJwt Mongoose method) we included the expiry date in an exp property. But if you look at a JWT, it seems to be a random string, like this following example:

eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJfaWQiOiI1NWQ0MjNjMTUxMzcxMmNkMzE3YTRkYT ciLCJlbWFpbCI6InNpbW9uQGZ1bGxzdGFja3RyYWluaW5nLmNvbSIsIm5hbWUiOiJTaW1vbiBIb2xtZ XMiLCJleHAiOjE0NDA1NzA5NDUsImlhdCI6MTQzOTk2NjE0NX0.jS50GlmolxLoKrA_24LDKaW3vNaY 94Y9EqYAFvsTiLg

So how do you read a JWT?

A JWT is actually made up of three separate strings, separated by a dot .. These three parts are:

Header — an encoded JSON object containing the type and the hashing algorithm used

Payload — an encoded JSON object containing the data, the real body of the token

Signature — an encrypted hash of the header and payload, using the “secret” set on the server.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.